<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>doh.robot Editor LinkDialog Plugin Test</title>

		<style>
			@import "../../../../util/doh/robot/robot.css";
		</style>

		<!-- required: dojo.js -->
		<script type="text/javascript" src="../../../../dojo/dojo.js"
			djConfig="isDebug: true, parseOnLoad: true"></script>

		<!-- functions to help test -->
		<script type="text/javascript" src="../../helpers.js"></script>

		<script type="text/javascript">
			dojo.require("dijit.dijit"); // optimize: load dijit layer
			dojo.require("dijit.robotx");

			dojo.addOnLoad(function(){
				doh.robot.initRobot('../test_LinkDialog.html');

				var editor;
				var ldPlugin;
				var value;
				var node;

				doh.register("LinkDialog_tests", [
					{
						name: "Anchor Tag: Create a new link",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);
								var url, desc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									url.attr("value", "http://example.com/");
									desc.attr("value", "This is my example link.");
								},2000);
								doh.robot.mouseMoveAt(function(){return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode;}, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertTrue(new RegExp("href=(\"|\')http://example.com/(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertFalse(new RegExp("<li><a").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("target=(\"|\')_self(\"|\')").test(newVal), "Verifying target has been inserted.");
									doh.assertTrue(new RegExp(">This is my example link.<").test(newVal), "Verifying description has been inserted.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Anchor Tag: Create a new link with alternate target",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);

								var url, target, desc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									target = dijit.byId(ldPlugin._uniqueId + "_targetSelect");
									url.attr("value", "http://example.com/");
									desc.attr("value", "This is my example link.");
									target.attr("value", "_blank");
								},2000);
								doh.robot.mouseMoveAt(function(){return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode;}, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><a").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("href=(\"|\')http://example.com/(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertTrue(new RegExp("target=(\"|\')_blank(\"|\')").test(newVal), "Verifying target has been inserted.");
									doh.assertTrue(new RegExp(">This is my example link.<").test(newVal), "Verifying description has been inserted.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Anchor Tag: Test auto insertion of http:// for urls.",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);

								var url, desc, target;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									target = dijit.byId(ldPlugin._uniqueId + "_targetSelect");
									url.attr("value", "example.com/");
									desc.attr("value", "This is my example link.");
									target.attr("value", "_blank");
								},2000);
								doh.robot.mouseMoveAt(function(){return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode;}, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><a").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("href=(\"|\')http://example.com/(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertTrue(new RegExp("target=(\"|\')_blank(\"|\')").test(newVal), "Verifying target has been inserted.");
									doh.assertTrue(new RegExp(">This is my example link.<").test(newVal), "Verifying description has been inserted.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Anchor Tag: Test insertion 'relative' urls.",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);

								var url, desc, target;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									target = dijit.byId(ldPlugin._uniqueId + "_targetSelect");
									url.attr("value", "./myDirectory/myfile.html");
									desc.attr("value", "This is my example relative link.");
									target.attr("value", "_blank");
								},2000);
								doh.robot.mouseMoveAt(function(){return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode;}, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><a").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("href=(\"|\')./myDirectory/myfile.html(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertTrue(new RegExp("target=(\"|\')_blank(\"|\')").test(newVal), "Verifying target has been inserted.");
									doh.assertTrue(new RegExp(">This is my example relative link.<").test(newVal), "Verifying description has been inserted.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Anchor Tag: Update existing anchor tag",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							dojo.withGlobal(editor.window, function(){
								node = dojo.byId("exampleLink");
							});
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();
							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");

								doh.robot.sequence(function(){
									// Okay, select the text of the hyperlink so we can then perform an edit on it.
									editor._sCall("selectElement", [node]);
								},500);
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);
								var url, desc, target, oldUrl, oldDesc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									target = dijit.byId(ldPlugin._uniqueId + "_targetSelect");

									oldUrl = url.attr("value");
									oldDesc = desc.attr("value");

									url.attr("value", oldUrl + "_2");
									desc.attr("value", oldDesc + "_2");
									target.attr("value", "_blank");
								}, 2000);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertTrue(new RegExp("href=(\"|\')"+ oldUrl + "_2" + "(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertFalse(new RegExp("href=(\"|\')"+ oldUrl + "(\"|\')").test(newVal), "Verifying old URL is gone.");
									doh.assertFalse(new RegExp("<li><a").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("target=(\"|\')_blank(\"|\')").test(newVal), "Verifying target has been inserted.");
									doh.assertFalse(new RegExp("target=(\"|\')_self(\"|\')").test(newVal), "Verifying old target is removed.");
									doh.assertTrue(new RegExp(">" + oldDesc + "_2<").test(newVal), "Verifying description has been inserted.");
									doh.assertFalse(new RegExp(">" + oldDesc + "<").test(newVal), "Verifying old desc is gone.");
								}), 2000);
							}catch(e){
									d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Anchor Tag: Blank description invalid.",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							dojo.withGlobal(editor.window, function(){
								node = dojo.byId("exampleLink");
							});
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();
							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");

								doh.robot.sequence(function(){
									// Okay, select the text of the hyperlink so we can then perform an edit on it.
									editor._sCall("selectElement", [node]);
								},500);
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);
								var url, desc, target, oldDesc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									target = dijit.byId(ldPlugin._uniqueId + "_targetSelect");
									oldDesc = desc.attr("value");
									desc.attr("value", "");
									target.attr("value", "_blank");
								}, 2000);
								doh.robot.sequence(function(){
									// Verify setting the content is disabled.
									var setButton = dijit.byId(ldPlugin._uniqueId + "_setButton");
									doh.assertTrue(setButton.attr("disabled"));
								}, 500);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_cancelButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal === value, "Verify the contents have not changed.");
								}), 2000);
							}catch(e){
									d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Anchor Tag: Test invalid url.",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.LinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);

								var url, desc, target;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									target = dijit.byId(ldPlugin._uniqueId + "_targetSelect");
									url.attr("value", "http://this is not/valid/bad.html");
									desc.attr("value", "This is my example relative link.");
									target.attr("value", "_blank");
									url.validate();
								},2000);
								doh.robot.sequence(function(){
									var setButton = dijit.byId(ldPlugin._uniqueId + "_setButton");
									doh.assertTrue(setButton.attr("disabled"));
								}, 500);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_cancelButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.mouseMoveAt(editor.iframe, 500, null, 0, 0);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal === value, "Verify the contents have not changed.");
									doh.assertFalse(url.isValid());
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Image Tag: Create a new image",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.ImgLinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the image dialog.");
								var value = editor.attr("value");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);

								var url, desc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									url.attr("value", "./sample2.jpg");
									desc.attr("value", "This is my example image 2.");
								},2000);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><img").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("src=(\"|\').*/sample2.jpg(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertTrue(new RegExp("alt=(\"|\')This is my example image 2.(\"|\')").test(newVal), "Verifying alt description has been inserted.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Image Tag: Verify http:// is prepended",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.ImgLinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the image dialog.");
								var value = editor.attr("value");
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);

								var url, desc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									url.attr("value", "example.com/example.jpg");
									desc.attr("value", "This is my example image.");
								},2000);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><img").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("src=(\"|\')http://example.com/example.jpg(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertTrue(new RegExp("alt=(\"|\')This is my example image.(\"|\')").test(newVal), "Verifying alt description has been inserted.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Image Tag: Update existing image tag",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.ImgLinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							dojo.withGlobal(editor.window, function(){
								node = dojo.byId("exampleImage");
							});
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");

								doh.robot.sequence(function(){editor._sCall("selectElement", [node]);}, 500);
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);
								var url, desc, oldDesc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									oldDesc = desc.attr("value");
									url.attr("value", "./sample2.jpg");
									desc.attr("value", oldDesc + "_2");
								}, 2000);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><img").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("src=(\"|\')"+ ".*/sample2.jpg" + "(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertFalse(new RegExp("src=(\"|\')"+ ".*/sample.jpg" + "(\"|\')").test(newVal), "Verifying old URL is gone.");
									doh.assertTrue(new RegExp("alt=(\"|\")" + oldDesc + "_2" + "(\"|\')").test(newVal), "Verifying description has been inserted.");
									doh.assertFalse(new RegExp("alt=(\"|\")" + oldDesc + "(\"|\')").test(newVal), "Verifying old desc is gone.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					},
					{
						name: "Image Tag: Blank description valid.",
						timeout: 20000,
						setUp: function(){
							editor = dijit.byId("editor");
							ldPlugin = null;
							var edPlugins = editor._plugins, i;
							for(i = 0; i < edPlugins.length; i++){
								var p = edPlugins[i];
								if(p.declaredClass === "dijit._editor.plugins.ImgLinkDialog"){
									ldPlugin = p;
									break;
								}
							}
							dojo.withGlobal(editor.window, function(){
								node = dojo.byId("exampleImage");
							});
							value = editor.attr("value");
						},
						runTest: function(){
							var d = new doh.Deferred();

							try{
								//Focus on the editor window
								dijit.scrollIntoView(editor.domNode);
								editor.focus();
								doh.robot.mouseMoveAt(editor.iframe, 500);
								doh.robot.mouseClick({left:true}, 500);

								//Find the fullscreen plugin, we'll need it.
								doh.assertTrue(ldPlugin !== null, "Verifying the link dialog.");
								var value = editor.attr("value");

								doh.robot.sequence(function(){editor._sCall("selectElement", [node]);}, 500);
								doh.robot.mouseMoveAt(ldPlugin.button.domNode, 500);
								doh.robot.mouseClick({left:true}, 500);
								var url, desc, oldDesc;
								doh.robot.sequence(function(){
									url = dijit.byId(ldPlugin._uniqueId + "_urlInput");
									desc = dijit.byId(ldPlugin._uniqueId + "_textInput");
									oldDesc = desc.attr("value");
									url.attr("value", "./sample2.jpg");
									desc.attr("value", "");
								}, 2000);
								doh.robot.sequence(function(){
									// Verify setting the content is disabled.
									var setButton = dijit.byId(ldPlugin._uniqueId + "_setButton");
									doh.assertFalse(setButton.attr("disabled"));
								}, 500);
								doh.robot.mouseMoveAt(function(){ return dijit.byId(ldPlugin._uniqueId + "_setButton").domNode; }, 500);
								doh.robot.mouseClick({left:true}, 500);
								doh.robot.sequence(d.getTestCallback(function(){
									//Now check the state!
									var newVal = editor.attr("value");
									doh.assertTrue(newVal !== value, "Verify the contents have changed.");
									doh.assertFalse(new RegExp("<li><img").test(newVal), "Verifying insert did not occur in the top li (IE test for selection restore.)");
									doh.assertTrue(new RegExp("src=(\"|\')"+ ".*/sample2.jpg" + "(\"|\')").test(newVal), "Verifying URL has been inserted.");
									doh.assertFalse(new RegExp("src=(\"|\')"+ ".*/sample.jpg" + "(\"|\')").test(newVal), "Verifying old URL is gone.");
									doh.assertTrue(new RegExp("alt=(\"|\")(\"|\')").test(newVal), "Verifying description has been cleared.");
									doh.assertFalse(new RegExp("alt=(\"|\")" + oldDesc + "(\"|\')").test(newVal), "Verifying old desc is gone.");
								}), 2000);
							}catch(e){
								d.errback(e);
							}
							return d;
						},
						tearDown: function(){
							if(editor){editor.attr("value", value);}
						}
					}
				]);
				doh.run();
			});
		</script>
	</head>
</html>
